<template>
	<view class="goodsDetail">
		<view class="top_view">
			<scroll-view class="top_scrollview" scroll-y="true" >
				<image :src="goodsItem.primaryPicUrl" mode=""></image>
				<view class="content">
					<view class="goodsDesc">{{goodsItem.promotionDesc}}</view>
					<view class="goodsPrice">
						￥  {{goodsItem.limitedFlag}}
					</view>
					<view class="simpleDesc">
						{{goodsItem.simpleDesc}}
					</view>
				</view>
			</scroll-view>
		</view>
		<view class="bottom_view">
				<image src="../../static/logo.png" mode=""></image>
				<view class="actionButtonView">
					<view class="buy">
						立即购买
					</view>
					<view class="add_car" @click="addGoodsItemToCart()">
						加入购物车
					</view>
				</view>
		</view>
	</view>
</template>

<script>
	import { mapMutations} from 'vuex';
	export default {
		data() {
			return {
				goodsItem:{}, 
			};
		},
		onLoad(options) {
			 this.goodsItem = JSON.parse(options.goodsItem)
			 console.log(this.goodsItem)
		},
		
		methods:{
			... mapMutations('cart',["addGoodsItemMutation"]),
			addGoodsItemToCart(){
				this.addGoodsItemMutation(this.goodsItem)
			}
		}
	}
</script>

<style lang="stylus">
	.goodsDetail
		width: 100%
		height: 100%
		.top_view
			background-color: #fff
			height: calc(100vh - 120rpx)
			.top_scrollview
				width: 100%
				height: calc(100vh - 120rpx)
				text-align: center
				image
					height: 640rpx
				.content
					width: 90%
					margin: auto
					.goodsDesc
						height: 80rpx
						line-height: 80rpx
						background-color: #ff5500
						color: #fff
						border-radius: 20rpx
					.goodsPrice
						margin-top: 10rpx
						color: red
						font-size: 38rpx
						text-align: left
					.simpleDesc
						margin-top: 10rpx
						font-size: 30rpx
						text-align: left
		.bottom_view
			background-color: #fff
			height: 120rpx
			width: 100%
			display: flex
			align-items: center
			justify-content: space-between
			border-top: 1px solid #ccc
			image
				width: 60rpx
				height: 60rpx
				margin-left: 40rpx
			.actionButtonView
				height: 100%
				display: flex
				justify-content: space-around
				align-items: center
				.buy
					height: 100%
					line-height: 120rpx
					width:240rpx
					text-align: center
				.add_car
					height: 100%
					line-height: 120rpx
					text-align: center
					width:240rpx
					background-color: red
					color: #fff
	.test
		background-color: #fff
</style>
